﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Login.Common;

namespace Login.Controllers
{
    public class BaseController : Controller
    {

        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            PracticeEntities1 entity = new PracticeEntities1();
            if (Request.Cookies["ID"].Value=="")
                Response.Redirect("/User/login");
            else
            {
                var ID = Encryp.DesDecrypt(Request.Cookies["ID"].Value.ToString());
                var user = entity.User.Find(Convert.ToInt32(ID));
                if (user == null)
                    Response.Redirect("/User/login");
            }
            base.OnActionExecuting(filterContext);
        }

        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            base.OnActionExecuted(filterContext);
        }
    }
}